﻿
using System.Linq;
using System.Web.Mvc;
using Gola.VN.Scb.Web.Common.Models;
using Gola.VN.Scb.Web.Presentation.Helpers;
using Gola.VN.Scb.Web.Presentation.Models;

namespace Gola.VN.Scb.Web.Presentation.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        //Todo: Create new home page
        public ActionResult Index()
        {
            ViewData["Title"] = Utilities.GetTitle("");
            HomeModels models = new HomeModels
                                    {
                                        // Categories = CategoryService.LeftPanelData,//todo: replace by ngocbv
                                        Categories = MainService.GetInstant().CategoryService.LeftPanelData,
                                        DisplayingCategories =
                                            MainService.GetInstant().ProductService.DisplayingCategories,
                                        // MostProviderProducts = ProductService.AllProducts.Take(10).ToList(), //todo: ngocbv
                                        HostProducts1 =
                                            MainService.GetInstant().ProductService.GetHostProducts().Take(4).ToList(),
                                        HostProducts2 =
                                            MainService.GetInstant().ProductService.GetHostProducts().Skip(4).Take(4).
                                            ToList(),
                                        HostProducts3 =
                                            MainService.GetInstant().ProductService.GetHostProducts().Skip(4 * 2).Take(4).
                                            ToList(),
                                        HostProducts4 =
                                            MainService.GetInstant().ProductService.GetHostProducts().Skip(4 * 3).Take(4).
                                            ToList(),
                                        RandomProducts1 = MainService.GetInstant().ProductService.GetRandomProducts(),
                                        RandomProducts2 = MainService.GetInstant().ProductService.GetRandomProducts(),
                                        RandomProducts3 = MainService.GetInstant().ProductService.GetRandomProducts(),
                                        RandomProducts4 = MainService.GetInstant().ProductService.GetRandomProducts(),
                                        OneWeekProducts =
                                            MainService.GetInstant().ProductService.GetProducts().OrderBy(
                                                p => p.ViewCount).Take(14).ToList(),
                                        ProviderLocations =
                                            //ProviderService.GetProviderAllLocations(), todo: HuyNN
                                            MainService.GetInstant().ProviderService.GetProviderAllLocations()
                                    };

            // ViewData["CloudData"] = CategoryService.GetCloudCategory(0); //todo: replaced by ngocbv
            ViewData["CloudData"] = MainService.GetInstant().CategoryService.GetCloudCategory(0);
            return View(models);
        }

        public ActionResult Index_Old()
        {
            ViewData["Title"] = Utilities.GetTitle("");
            HomeModels models = new HomeModels
                                    {
                                        // Categories = CategoryService.LeftPanelData,//todo: replace by ngocbv
                                        Categories = MainService.GetInstant().CategoryService.LeftPanelData,
                                        // MostProviderProducts = ProductService.AllProducts.Take(10).ToList(), //todo: ngocbv
                                        MostProviderProducts =
                                            MainService.GetInstant().ProductService.GetProducts().Take(10).ToList(),
                                        NewChangePriceProducts =
                                            // ProductService.AllProducts.OrderBy(p => p.Price).Take(10).ToList(), //todo: ngocbv
                                            MainService.GetInstant().ProductService.GetProducts().OrderBy(p => p.Price).
                                            Take(10).ToList(),
                                        NewUpdateProducts =
                                            // ProductService.AllProducts.OrderByDescending(p => p.CreateDate).Take(10).ToList(), //todo: ngocbv
                                            MainService.GetInstant().ProductService.GetProducts().OrderByDescending(
                                                p => p.CreateDate).Take(10).ToList(),
                                        OneMonthProducts =
                                            // ProductService.AllProducts.OrderByDescending(p => p.CreateDate).Take(10).ToList(), //todo:ngocbv
                                            MainService.GetInstant().ProductService.GetProducts().OrderByDescending(
                                                p => p.CreateDate).Take(10).ToList(),
                                        OneWeekProducts =
                                            // ProductService.AllProducts.OrderByDescending(p => p.CreateDate).Take(10).ToList(), //todo: ngocbv
                                            MainService.GetInstant().ProductService.GetProducts().OrderByDescending(
                                                p => p.CreateDate).Take(10).ToList(),
                                        ProviderLocations =
                                            //ProviderService.GetProviderAllLocations(), todo: HuyNN
                                            MainService.GetInstant().ProviderService.GetProviderAllLocations()
                                    };

            // ViewData["CloudData"] = CategoryService.GetCloudCategory(0); //todo: replaced by ngocbv
            ViewData["CloudData"] = MainService.GetInstant().CategoryService.GetCloudCategory(0);
            return View(models);
        }

        public ActionResult About()
        {
            return View();
        }
    }
}